using Framework.Audio;
using Framework.FSMLite;
using Framework.UI;

namespace GameSystem
{
    public class StateLoading: StateMachine<GameEnum>
    {

        private GameEnum _toState;


        internal override void OnEnter(params object[] args)
        {
            AudioManager.Instance.StopPlayers(0 , 1);
            AudioManager.Instance.StopPlayers(1 , 1);
            this._toState = (GameEnum) args[0];
            float inTime = this._toState == GameEnum.Game ? 1.5f : 0.75f;
            UIManager.OpenLoading(inTime, 4, inTime, this.LoadingEnd);
        }

        private void LoadingEnd()
        {
            this.stateMachineRunner.ChangeState(this._toState);
        }

        internal override void OnExit() { }

    }
}